<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      :border="false"
      fit
      style="width: 100%;"
    >
      <el-table-column label="ID" width="80">
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="会员ID">
        <template slot-scope="{row}">
          <span>{{row.user_id}}</span>
        </template>
      </el-table-column>
      <el-table-column label="团队总盒数">
        <template slot-scope="{row}">
          <span>{{row.team_box}}</span>
        </template>
      </el-table-column>
      <el-table-column label="团队业绩补贴">
        <template slot-scope="{row}">
          <span>{{row.team_amount_1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="团队旅游补贴">
        <template slot-scope="{row}">
          <span>{{row.team_amount_2}}</span>
        </template>
      </el-table-column>
      <el-table-column label="团队差旅补贴">
        <template slot-scope="{row}">
          <span>{{row.team_amount_3}}</span>
        </template>
      </el-table-column>
      <el-table-column label="团队会议补贴">
        <template slot-scope="{row}">
          <span>{{row.team_amount_4}}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际盒数">
        <template slot-scope="{row}">
          <span>{{row.box}}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际业绩补贴">
        <template slot-scope="{row}">
          <span>{{row.amount_1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际旅游补贴">
        <template slot-scope="{row}">
          <span>{{row.amount_2}}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际差旅补贴">
        <template slot-scope="{row}">
          <span>{{row.amount_3}}</span>
        </template>
      </el-table-column>
      <el-table-column label="实际会议补贴">
        <template slot-scope="{row}">
          <span>{{row.amount_4}}</span>
        </template>
      </el-table-column>
      <el-table-column label="总佣金">
        <template slot-scope="{row}">
          <span style="color:red;">{{+row.amount_1 + +row.amount_2 + +row.amount_3 + +row.amount_4}}</span>
        </template>
      </el-table-column>
      <el-table-column label="分红时间" width="160">
        <template slot-scope="{row:{create_time}}">
          <i class="el-icon-time" />
          <span style="margin-left: 5px">{{ create_time | timeFilter }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" width="160">
        <template slot-scope="{row}">
          <i class="el-icon-time" />
          <span style="margin-left: 5px">{{ row.update_time | timeFilter }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import waves from '@/directive/waves'
import api from '@/api'
import { parseTime } from '@/utils'

export default {
  name: 'MemberProfit',
  directives: { waves },
  filters: {
    timeFilter(time) {
      return time ? parseTime(time, '{m}-{d} {h}:{i}') : ''
    }
  },
  data() {
    return {
      listLoading: false,
      list: []
    }
  },
  created() {
  },
  mounted() {
    this.getList()
  },
  methods: {
    /**
     * 获取数据列表
     */
    getList() {
      this.listLoading = true
      api.member.profitList().then(response => {
        const { data } = response
        this.list = data.list
      }).finally(() => {
        this.listLoading = false
      })
    }
  }
}
</script>
